package image.filter;

/**
 * @author chiche
 * 
 */
public class MeanFilter extends Filter {

	private double ponderador;

	public MeanFilter(int dimension) {
		this.dimension = dimension;
		this.ponderador = 1.0d / dimension * dimension;
	}

	

	/**
	 * calcula la media
	 */
	protected int calculateValue(int[][] mask) {
		int ans = 0;
		for (int i = 0; i < mask.length; i++) {
			for (int j = 0; j < mask[i].length; j++) {
				ans += mask[i][j];
			}
		}
		// System.out.println("ans" + ans);
		// System.out.println("mean" +
		// (int)Math.floor((double)1/(ans*ponderador)));
		return (int) Math.floor(ans * ponderador);
	}
}
